package com.bupt.liutong.admin.bbs.dao;

import java.util.List;

import com.bupt.liutong.admin.bbs.dto.Board;
import com.bupt.liutong.admin.core.base.Ibatis;

public class BoardDao {

	private Ibatis ibatis;

	@SuppressWarnings("unchecked")
	public List<Board> getBoardsByPage(Board board) {
		return (List<Board>) ibatis.queryForPage("bbs_board.getBoards", board);
	}

	@SuppressWarnings("unchecked")
	public List<Board> getBoards(Board board) {
		return (List<Board>) ibatis.queryForList("bbs_board.getBoards", board);
	}

	public Board getBoardById(int id) {
		return (Board) ibatis.queryForObject("bbs_board.getBoardById", id);
	}
	
	@SuppressWarnings("unchecked")
	public List<Board> getAllBoards(){
		return (List<Board>) ibatis.queryForList("bbs_board.getBoards");
	}

	public void insertBoard(Board board) {
		ibatis.insert("bbs_board.insertBoard", board);
	}

	public void updateBoard(Board board) {
		ibatis.update("bbs_board.updateBoard", board);
	}

	public void deleteBoard(int id) {
		ibatis.delete("bbs_board.deleteBoard", id);
	}

	public void setIbatis(Ibatis ibatis) {
		this.ibatis = ibatis;
	}
}
